package com.microservice.salmon.db.mapper;

import com.microservice.salmon.db.entities.Cart;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CartMapper extends Mapper<Cart> {
    /**
     * 获取购物车中选中的条目
     * @param userId 用户ID
     * @return
     */
    List<Cart> selectCheckedCartByUserId(Integer userId);

    List<Cart> selectCartByUserId(Integer userId);

    /**
     * 根据用户ID和产品ID获取购物车
     * @param userId 用户ID
     * @param goodsId 商品ID
     * @return
     */
    Cart selectCartByUserIdAndGoodsId(@Param("userId") Integer userId, @Param("goodsId")Integer goodsId);

    int selectCartGoodsCheckedStatusByUserId(@Param("userId") Integer userId);

    int deleteByUserIdGoodsIds(@Param("userId") Integer userId,@Param("goodsIdList")List<String> goodsIdList);


    int selectCartGoodsCount(@Param("userId") Integer userId);

    int checkedOrUncheckedGoods(@Param("userId") Integer userId,@Param("goodsId")Integer goodsId, @Param("checked") Integer checked);


}